﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc;

using log4net;
using AutoFacUtils;
using Common;
using CashFlow.Db.Entity;
using CashFlow.Admin.Service;
using CashFlow.Admin.Common;

namespace CashFlow.Admin.Controllers
{
    public class HomeController : Controller
    {
        private static readonly ILog _logger = LogManager.GetLogger(typeof(HomeController));
        private IAdminService GetAdminService() { return AutoFacHelper.Get<IAdminService>(); }

        public ActionResult Index()
        {
            var service = GetAdminService();
            ViewBag.IsAdminnistrator = service.IsAdministrator();
            ViewBag.AdminInfo = service.GetLoginUserInfo();
            return View();
        }

        public ActionResult Logout()
        {
            Session.Clear();
            Response.Cookies.Clear();

            return Redirect(MyConfig.AuthenticationSection.Forms.LoginUrl);
        }
    }
}